from django.db import models


# 商家表
class Shops(models.Model):
    shops_name = models.CharField(max_length=30,verbose_name='商家名称')
    shops_mobile = models.CharField(max_length=11,verbose_name='联系电话')
    shops_slogan = models.CharField(max_length=30,null=True,verbose_name='商家标语')
    shops_address = models.CharField(max_length=120,verbose_name='商家地址')
    logo = models.CharField(max_length=800,null=True,verbose_name='商家logo')
    score = models.DecimalField(max_digits=2,decimal_places=1,verbose_name='商家评分')
    open_time = models.DateTimeField(null=True,verbose_name='营业时间')
    end_time = models.DateTimeField(null=True,verbose_name='结束时间')
    sending_fee = models.IntegerField(default=0,verbose_name='起送费')
    user = models.ForeignKey('users.UserModel',on_delete=models.CASCADE,verbose_name='用户商家')
    class Meta:
        db_table ='shops_tb'
        verbose_name = '商家表'
        verbose_name_plural=verbose_name
    def __str__(self):
        return '商家名称：%s'%self.shops_name


# 商家优惠券
class Shops_Coupon(models.Model):
    coupon_name = models.CharField(max_length=30,verbose_name='优惠券名称')
    coupon_details = models.CharField(max_length=30,verbose_name='优惠券详情')
    coupon_price = models.DecimalField(max_digits=6,decimal_places=2,verbose_name='优惠券价格')
    start_time = models.DateTimeField(null=True,verbose_name='优惠券开始时间')
    over_time = models.DateTimeField(null=True,verbose_name='优惠券结束时间')
    shops = models.ForeignKey(Shops,on_delete=models.CASCADE,verbose_name="商家id")
    class Meta:
        db_table="shops_coupon_tb"
        verbose_name_plural="商家的优惠券"
    def __str__(self):
        return '优惠券名称%s'%self.coupon_name



# 种类
class Kind(models.Model):
    kind_name = models.CharField(max_length=30,verbose_name='种类名称')
    shops = models.ForeignKey(Shops,on_delete=models.CASCADE,verbose_name="商家id")
    class Meta:
        db_table="kind_tb"
        verbose_name_plural="菜品种类表"
    def __str__(self):
        return '菜品种类%s'%self.kind_name



# 菜品
class Dishes(models.Model):
    dishes_name = models.CharField(max_length=30,verbose_name='菜品名称')
    dishes_price = models.DecimalField(max_digits=5,decimal_places=2,verbose_name='菜品价格')
    dishes_picture = models.CharField(max_length=600,null=True,verbose_name='菜品图片')
    kind = models.ForeignKey(Kind,on_delete=models.CASCADE,verbose_name='菜品种类')
    shops = models.ForeignKey(Shops,on_delete=models.CASCADE,verbose_name='所属商家')
    class Meta:
        db_table ='dishes_tb'
        verbose_name = '菜品表'
        verbose_name_plural = verbose_name
    def __str__(self):
        return '菜品名称%s'%self.dishes_name







